package ru.hh.team02.chat.messaging;

import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;

/**
 * Personal message.
 * Because of slow db access implemented with futures
 */
public class UnfinishedPersonalMessage implements Message {
    private final String text;
    private FutureTask<Integer> Id;

    public String getText() {
        try {
            return " " + Id.get() + " " + text;
        } catch (InterruptedException e) {
            e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
        } catch (ExecutionException e) {
            e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
        }
        return "";
    }

    public boolean isPersonal() {
        return true;
    }

    /**
     * Create a message.
     *
     * @param text
     *            Message text
     */
    public UnfinishedPersonalMessage(String text, FutureTask<Integer> Id) {
        this.text = text;
        this.Id = Id;
    }

}
